package com.gin.no_gay_alliance.adpter;

import android.content.Context;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;

import com.gin.no_gay_alliance.adpter.base.BaseBindingRecyclerViewAdapter;
import com.gin.no_gay_alliance.customview.ItemView;
import com.gin.no_gay_alliance.databinding.ItemViewBinding;
import com.gin.no_gay_alliance.viewmodel.ItemModel;

import java.util.List;

/**
 * 道具适配器
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/9/7 16:53
 **/
public class ItemViewAdapter extends BaseBindingRecyclerViewAdapter<ItemViewBinding, ItemModel> {
    @NonNull
    private ItemView.Params params;

    public ItemViewAdapter(Context context) {
        super(context);
    }

    public ItemViewAdapter(@NonNull Context context, @NonNull List<ItemModel> data) {
        super(context, data);
    }

    /**
     * 绑定数据
     *
     * @param holder
     * @param b        绑定对象
     * @param position 位置
     * @param item
     */
    @Override
    protected void onBindViewHolder(ViewHolder<ItemViewBinding> holder, @NonNull ItemViewBinding b, int position, ItemModel item) {
        b.getRoot().init(item, params);
    }

    /**
     * 构造binding对象
     *
     * @param inflater
     * @return T
     */
    @NonNull
    @Override
    protected ItemViewBinding buildBinding(LayoutInflater inflater) {
        return ItemViewBinding.inflate(inflater);
    }

    /**
     * @return 是否应用斑马纹配色
     */
    @Override
    protected boolean useZebraStripe() {
        return false;
    }

    public void setParams(@NonNull ItemView.Params params) {
        this.params = params;
    }

}
